//强制类作用域中的方法在预期范围内调用 反例
class MyClass {
  public logUnbound(): void {
    this.logUnbound1();
  }

  public logBound = () => {
    this.logUnbound2();
  };
}

const instance = new MyClass();

//反例
class MyClass {
  public log(): void {
    console.log(this);
  }
}

const instance = new MyClass();

// This logs the global scope (`window`/`global`), not the class instance
const myLog = instance.log;
myLog();

// arith.double may refer to `this` internally
const arith = {
  double(x: number): number {
    return x * 2;
  },
};
const { double } = arith;

//反例
class Console {
  log(str) {
    process.stdout.write(str);
  }
}

const console = new Console();

Promise.resolve().then(console.log);

import { console } from './class';
const x = console.log;

//反例
class Foo {
  unbound() {}
}
const instance = new Foo();

let x;

x = instance.unbound; // THIS SHOULD ERROR
instance.unbound = x; // THIS SHOULD NOT

//反例
class Foo {
  unbound = function () {};
}
const unbound = new Foo().unbound;

class Foo {
  unbound() {}
}
const { unbound } = new Foo();

class Foo {
  unbound = function () {};
}
const { unbound } = new Foo();

class Foo {
  unbound() {}
}
let unbound;
({ unbound } = new Foo());

//反例
class Foo {
  unbound = function () {};
}
let unbound;
({ unbound } = new Foo());

class CommunicationError {
  foo() {}
}
const { foo } = CommunicationError.prototype;

class CommunicationError {
  foo() {}
}
let foo;
({ foo } = CommunicationError.prototype);

//反例
import { console } from './class';
const { log } = console;

const { all } = Promise;

//反例
class BaseClass {
  logThis() {}
}
class OtherClass extends BaseClass {
  constructor() {
    super();
    let x;
    x = super.logThis;
  }
}

const values = {
  a() {},
  b: () => {},
};
const { a, b } = values;

const values = {
  a() {},
  b: () => {},
};
const { b, a } = values;

const objectLiteral = {
  f: function () {},
};
const f = objectLiteral.f;

